<?php

namespace App\Http\Middleware;


use App\Exceptions\UserMessageException;
use App\Models\User;
use Closure;

class UserMessageCheck
{

    /**
     * @param $request
     * @param Closure $next
     * @return mixed
     * @throws UserMessageException
     */
    public function handle($request, Closure $next)
    {
        // 获取用户token
        $user = User::whereKey(UID)->first();

        if (filled($user) && filled($user->nick_name)) {
            return $next($request);
        }

        throw new UserMessageException();
    }
}
